home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6860 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.2 KB  |  70 lines

  1. Newsgroups: comp.lang.c++
  2. Path: netcom.com!marnold
  3. From: marnold@netcom.com (Matt Arnold)
  4. Subject: Re: Is there a standard for * and & placement style?
  5. Message-ID: <marnoldDn27q9.Is0@netcom.com>
  6. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  7. References: <3128BD31.4AF8@wildfire.com>
  8. Date: Tue, 20 Feb 1996 05:39:45 GMT
  9. Sender: marnold@netcom12.netcom.com
  10.  
  11. Stonewall Ballard <stoney@wildfire.com> writes:
  12.  
  13. >I'm trying to find out whether there is a "standard" for the 
  14. >placement of * and &. A survey of C++ texts shows that most use
  15.  
  16. >Form 1
  17. >  int&  foo;
  18. >  int*  foo;
  19.  
  20. >while some use
  21.  
  22. >Form 2
  23. >  int&  foo;
  24. >  int  *foo;
  25.  
  26. >and nobody uses (although I've seen this a lot in code)
  27.  
  28. >Form 3
  29. >  int  &foo;
  30. >  int  *foo;
  31.  
  32. I can't stand this form!
  33.  
  34. >The ARM and the latest C++ working paper both use form 1. The 
  35. >most well-known user of form 2 is Scott Meyers in his Effective 
  36. >C++ books. People I work with use form 3.
  37.  
  38. >Imagine that you were given a class framework to use and extend. 
  39. >Would you expect that the placement of & and * follow one of the 
  40. >above schemes? Do you perceive that there is a standard for the 
  41. >placement of * and &? If so, what is it?
  42.  
  43. There is probably no standard, just religiously held opinions.
  44.  
  45. >Please reply by email to stoney@wildfire.com
  46.  
  47. My personal preference is Form 1, and I have a logical reason:  It
  48. seems to me that that "pointer-ness" (*) or "reference-ness" (&) is
  49. certinaly part of the variable *type*, not part of the variable.  It
  50. therefore seems logical to associate * or & with type identifier 
  51. rather than the variable name.  For me, this creates a distinct 
  52. visual separation between types and variables.
  53.  
  54.  
  55. You forgot Form 4
  56.  
  57.   int & foo;
  58.   int * foo;
  59.  
  60. ;-)
  61.  
  62. Regards,
  63. -------------------------------------------------------------------------
  64. Matt Arnold                       |        | ||| | |||| |  | | || ||
  65. marnold@netcom.com                |        | ||| | |||| |  | | || ||
  66. Boston, MA                        |      0 | ||| | |||| |  | | || ||
  67. 617.389.7384 (h) 617.576.2760 (w) |        | ||| | |||| |  | | || ||
  68. C++, MIDI, Win32/95 developer     |        | ||| 4 3 1   0 8 3 || ||
  69. -------------------------------------------------------------------------
  70.